package com.netnovelstore.dao;

import com.netnovelstore.pojo.Book;
import com.netnovelstore.pojo.BookContent;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface BookMapper {
    List<Book> getBookList(Integer pageStart, Integer pageSize);

    @Select("select count(book_number) from tb_novel where deleted = 0")
    Integer countBookList();

    List<Book> searchBook(String keyword, Integer pageStart, Integer pageSize);

    Integer getCountBySearchBook(String keyword);

    //Type
    List<Book> getBookListByType(Integer pageStart, Integer pageSize, String type);

    Integer getCountBySearchBookByType(String type);

    //Free
    List<Book> getBookListByFree(Integer pageStart, Integer pageSize);

    Integer getCountBySearchBookByFree();

    //Full
    List<Book> getBookListByFull(Integer pageStart, Integer pageSize);

    Integer getCountBySearchBookByFull();

    //New
    List<Book> getBookListByNew(Integer pageStart, Integer pageSize);

    //hot
    List<Book> getBookListByHot(Integer pageStart, Integer pageSize);
    //advise
//    List<Book> getBookListByAdvise(Integer pageStart,Integer pageSize);
//    Integer getCountBySearchBookByAdvise();


    /**
     * @return java.lang.Boolean
     * @Author maotao
     * @Description 插入tb_novel书籍
     * @Date 10:55 2022/10/4
     * @Param [book]
     **/
    Boolean insertBookTo_tb_novel(Book book);

    /**
     * @return java.lang.Boolean
     * @Author maotao
     * @Description 插入tb_novel_attribute书籍
     * @Date 10:55 2022/10/4
     * @Param [book]
     **/
    Boolean insertBookTo_tb_novel_attribute(Book book);

    /**
     * @return java.lang.Boolean
     * @Author maotao
     * @Description 依 书籍编号 编辑 书籍
     * @Date 10:56 2022/10/4
     * @Param [book]
     **/
    Boolean updateBookByNumberTo_tb_novel(Book book);

    /**
     * @return java.lang.Boolean
     * @Author maotao
     * @Description 依 书籍编号 编辑 书籍
     * @Date 10:56 2022/10/4
     * @Param [book]
     **/
    Boolean updateBookByNumberTo_tb_novel_attribute(Book book);

    /**
     * @return java.lang.Boolean
     * @Author maotao
     * @Description 更新书籍访问人次
     * @Date 15:34 2022/10/4
     * @Param [quantity, bookNumber]
     **/
    Boolean updateQuantityByBookNumber(Integer quantity, Integer bookNumber);

    /**
     * @return java.lang.Boolean
     * @Author maotao
     * @Description 依 书籍编号 逻辑删除书籍
     * @Date 10:57 2022/10/4
     * @Param [numberList]
     **/
    Boolean deleteBooksByNumberList(List<Integer> numberList);

    /**
     * @return java.lang.String "1664947843244"
     * @Author maotao
     * @Description 根据书籍编号获取真实路径
     * @Date 16:31 2022/10/5
     * @Param [bookNumber]
     **/
    @Select("select count(id) from tb_novel_content where book_number = #{bookNumber}")
    Integer getPathByBookNumber(Integer bookNumber);


    Boolean insertBookTo_tb_novel_contentByForeach(BookContent bookContent);


    BookContent selectBookByBookContent(Integer bookNumber, Integer bookContentNumber);

    Integer isExistBookContentByBookContent(BookContent bookContent);

    @Select("select (book_number) from tb_novel where book_name = #{bookName} and deleted = 0")
    Integer getBookNumberByBookName(String bookName);


    List<Book> getBookAll();

}
